/**
 * ------------------------------------------------------
 *  路由配置
 * ------------------------------------------------------
 *
 * Note: .
 *
 */

import Layout from "@/pages/Layout";
import Login from "@/pages/Login";

import { createBrowserRouter } from "react-router-dom";
import { AuthRoute } from '@/components/AuthRoute'
import { lazy, Suspense } from "react";

//根据路由动态加载JS资源
const Home = lazy(()=>import('@/pages/Home'))
const Student = lazy(()=>import('@/pages/Student'))
const Publish = lazy(()=>import('@/pages/Student/Publish'))

const router = createBrowserRouter([
    {
        path:"/",
        element:<AuthRoute chliden={<Layout />} />,
        children:[
            {
                path:'home',
                element:<Suspense fallback={'加载中'}><Home/></Suspense>
            },
            {
                path:'student',
                element:<Suspense fallback={'加载中'}><Student/></Suspense>
            },
            {
                path:'student/publish',
                element:<Suspense fallback={'加载中'}><Publish/></Suspense>
            }
        ]
    },
    {
        path:"/login",
        element:<Login />
    }
])

export default router